package com.ideajava.test;

import java.util.List;

import com.geccocrawler.gecco.GeccoEngine;
import com.geccocrawler.gecco.annotation.Gecco;
import com.geccocrawler.gecco.annotation.HtmlField;
import com.geccocrawler.gecco.annotation.Request;
import com.geccocrawler.gecco.request.HttpGetRequest;
import com.geccocrawler.gecco.request.HttpRequest;
import com.geccocrawler.gecco.spider.HtmlBean;

/**
 * @Description :
 * @FileName: AllPage.java
 * @Author :WeiHui.Zhang
 * @Data : 2016年3月25日 下午2:44:55
 * @Version:V1.00
 */
@Gecco(matchUrl = "http://www.ideajava.org/articleIndex/{index}", pipelines = { "consolePipeline" })
public class AllPage implements HtmlBean {

	private static final long serialVersionUID = 665662335318691818L;

	@HtmlField(cssPath = "div.article-item")
	private List<Page> pages;
	
	@Request
	private HttpRequest request;
	
	public List<Page> getPages() {
		return pages;
	}

	public void setPages(List<Page> pages) {
		this.pages = pages;
	}
	
	public HttpRequest getRequest() {
		return request;
	}

	
	public void setRequest(HttpRequest request) {
		this.request = request;
	}

	public static void main(String[] args) {
		HttpGetRequest start = new HttpGetRequest("http://www.ideajava.org/articleIndex/1");
		start.setCharset("UTF-8");
		GeccoEngine.create().classpath("com.ideajava.test").start(start)
				// 开启几个爬虫线程
				.thread(1)
				// 单个爬虫每次抓取完一个请求后的间隔时间
				.interval(2000).run();
	}
}
